package StudyCode.summary.mycollection;

import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class TakesALinearArrayOfSize16AndConvertsItIntoA4x4StateArray {
	public static void main(String[] argv) {
		byte[] array = new byte[]{34, 35, 36, 37, 37, 37, 67, 68, 69, 1, 2, 3, 4, 5, 6, 7};
		byte[][] bytes = arrayTo4xArray(array);
		for (byte[] aByte : bytes) {
			System.out.println(Arrays.toString(aByte));
		}
	}

	public static byte[][] arrayTo4xArray(byte[] array) {

		byte[][] array4x = new byte[4][4];

		for (int i = 0; i < 4; i++) {
			System.arraycopy(array, (i * 4), array4x[i], 0, 4);
		}

		return array4x;
	}
}
